package com.keyroy.game.puzzle_rpg.dialogs;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import com.keyroy.game.puzzle_rpg.models.puzzle.PuzzleMap;
import com.keyroy.game.puzzle_rpg.views.PuzzleView;

public class PuzzleDemoDialog extends Shell {

	/**
	 * Launch the application.
	 * 
	 * @param args
	 */
	public static void main(String args[]) {
		try {
			Display display = Display.getDefault();
			PuzzleDemoDialog shell = new PuzzleDemoDialog(display, null);
			shell.open();
			shell.layout();
			while (!shell.isDisposed()) {
				if (!display.readAndDispatch()) {
					display.sleep();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the shell.
	 * 
	 * @param display
	 */
	public PuzzleDemoDialog(Display display, PuzzleMap puzzleMap) {
		super(display, SWT.DIALOG_TRIM);
		setLayout(new FillLayout(SWT.HORIZONTAL));

		PuzzleView puzzle_view = new PuzzleView(this);

		createContents();
		if (puzzleMap != null) {
			puzzle_view.setPuzzleMap(puzzleMap);
			setSize(puzzleMap.getWidth(), puzzleMap.getHeight() + 30);
		}
	}

	/**
	 * Create contents of the shell.
	 */
	protected void createContents() {
		setText("puzzle demo");
		setSize(450, 300);
	}

	@Override
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	}

}
